import * as XLSX from 'xlsx'
import { saveAs } from 'file-saver'
/**
 *@param {Array} data =[] 需要导出excel的数据
 *@param {string} name excel命名
 
 **/
export const exportExcel = ({ data, name }) => {
    const workbook = XLSX.utils.book_new()
    const worksheet = XLSX.utils.json_to_sheet(data)
    XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet 1')
    const excelData = XLSX.write(workbook, { type: 'array', bookType: 'xlsx' })
    const blob = new Blob([excelData], { type: 'application/octet-stream' })
    saveAs(blob, `${name}.xlsx`)
}